var showR21UpdateForm = function(id) {
	window.open('capply_preSubmit.do?copyrightApplication.id=' + id);
};

Ext.ns("crs.grid");

crs.grid.R21AppliededGridPanel = Ext.extend(Ext.grid.EditorGridPanel, {

	/* begin of fields initialization */
	autoHeight : true,
	default_url : 'capply_appliedRecords.do',
	defaultProxy : '',
	pageSize : 15,
	closable : true,
	params : '',
	root : 'listCopyrightApplication',
	totalProperty : 'pagination.totalCount',
	title : '著作权登记或转让申请记录',
	viewConfig : {
		deferEmptyText : false,
		emptyText : '没有可显示数据',
		forceFit : true
/*
 * , getRowClass : function(record, index) { var c = record.get('state'); if (c ==
 * 2) return 'review_success'; if (c == 1) { return 'not_review'; } if (c == 4) {
 * return 'review_refused'; } }
 */
	},
	params : {},
	defaultProxy : {},
	fields : ['id', 'name1', 'softFullName', 'editionNumber', 'state'],
	columns : [{
				header : '著作权人',
				dataIndex : 'name1'
			}, {
				header : '软件名称',
				dataIndex : 'softFullName'
			}, {
				header : '版本号',
				dataIndex : 'editionNumber'
			}, {
				header : '状态',
				dataIndex : 'state',
				renderer : function(v) {
					if (!v)
						return '待审核';
					if (v == 1) {
						return '待审核';
					} else if (v == 2) {
						return '审核通过';
					} else {
						return "审核不通过";
					}
				}
			}, {
				header : '操作',
				width : 100,
				dataIndex : 'id',
				renderer : function(value, metaData, record, rowIndex,
						colIndex, store) {

					if (!record.data.state)
						return '';

					// 未审核或审核失败，允许修改
					if (record.data.state != 2) {
						return "<a href='#' onclick='showR21UpdateForm("
								+ value + ")'>修改</a>";
					}

					return '';
				}
			}],
	sm : new Ext.grid.RowSelectionModel({
				singleSelect : true
			}),
	initComponent : function() {
		this.buildProxies();
		this.params = this.buildParams();
		this.store = this.buildStore();
		// this.columns = this.buildColumns();
		this.bbar = this.buildBbar();
		crs.grid.R21AppliededGridPanel.superclass.initComponent.call(this);

		this.store.load(this.params);
	},
	/* end of components appending to this panel */
	buildStore : function() {

		return new Ext.data.Store({
					proxy : this.defaultProxy,
					reader : new Ext.data.JsonReader({
								root : this.root,
								totalProperty : this.totalProperty,
								fields : this.fields
							})
				});

	},

	buildProxies : function() {

		this.defaultProxy = new Ext.data.HttpProxy({
					url : this.default_url,
					method : 'post'
				});
	},
	buildBbar : function() {
		return new Ext.PagingToolbar({
					store : this.store,
					pageSize : this.pageSize,
					displayInfo : true
				});
	},
	buildParams : function() {
		var dataPost = {};
		dataPost.params = {};
		dataPost.params.start = 0;
		dataPost.params.limit = this.pageSize;
		dataPost.params['pagination.start'] = 0;
		dataPost.params['pagination.pageSize'] = this.pageSize;
		return dataPost;
	}

		/* end of handler implementation */
	});

Ext.reg("r21_applied_grid", crs.grid.R21AppliededGridPanel);